home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / test / test.h < prev    next >
Text File  |  1993-12-06  |  3KB  |  109 lines

  1. /**
  2.  ** TEST.H
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24.  
  25. #ifndef _TEST_H_
  26. #define _TEST_H_
  27.  
  28. #include <grx.h>
  29. #include <mousex.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32.  
  33. #ifdef __TURBOC__
  34. # undef  random
  35. # define random() rand()
  36. # include <conio.h>
  37. #endif
  38.  
  39. #define TESTFUNC(name) \
  40.     void name(void); \
  41.     void (*testfunc)(void) = name; \
  42.     void name(void)
  43.  
  44. extern void (*testfunc)(void);
  45.  
  46. char exit_message[2000] = { "" };
  47.  
  48. int Argc;
  49. char **Argv;
  50.  
  51. void main(int argc,char **argv)
  52. {
  53.     int x = 0;
  54.     int y = 0;
  55.     int c = 0;
  56.  
  57.     Argc = argc - 1;
  58.     Argv = argv + 1;
  59.     if((Argc >= 2) &&
  60.        (sscanf(Argv[0],"%d",&x) == 1) && (x >= 320) &&
  61.        (sscanf(Argv[1],"%d",&y) == 1) && (y >= 200)) {
  62.         Argc -= 2;
  63.         Argv += 2;
  64.         if((Argc > 0) && (sscanf(Argv[0],"%d",&c) == 1) && (c >= 2)) {
  65.         Argc--;
  66.         Argv++;
  67.         }
  68.     }
  69.     if(c >= 2)
  70.         GrSetMode(GR_width_height_color_graphics,x,y,c);
  71.     else if((x >= 320) && (y >= 200))
  72.         GrSetMode(GR_width_height_graphics,x,y);
  73.     else GrSetMode(GR_default_graphics);
  74.     (*testfunc)();
  75.     GrSetMode(GR_default_text);
  76.     puts(exit_message);
  77.     exit(0);
  78. }
  79.  
  80. #define XP(x)    (int)((((long)(x) * (long)xsize) / 100L) + xpos)
  81. #define YP(y)    (int)((((long)(y) * (long)ysize) / 100L) + ypos)
  82.  
  83. void drawing(int xpos,int ypos,int xsize,int ysize,int fg,int bg)
  84. {
  85.     int ii;
  86.  
  87.     if(bg != GrNOCOLOR) {
  88.         GrFilledBox(xpos,ypos,xpos+xsize-1,ypos+ysize-1,bg);
  89.     }
  90.     GrLine(XP(10),YP(10),XP(40),YP(40),fg);
  91.     GrLine(XP(40),YP(10),XP(10),YP(40),fg);
  92.     GrLine(XP(35),YP(10),XP(65),YP(40),fg);
  93.     GrLine(XP(35),YP(40),XP(65),YP(10),fg);
  94.     GrLine(XP(70),YP(10),XP(90),YP(40),fg);
  95.     GrLine(XP(70),YP(40),XP(90),YP(10),fg);
  96.     for(ii = 0; ii < 5; ii++) {
  97.         GrBox(XP(70+2*ii),YP(10+3*ii),XP(90-2*ii),YP(40-3*ii),fg);
  98.     }
  99.     GrFilledBox(XP(10),YP(50),XP(60),YP(90),fg);
  100.     GrBox(XP(70),YP(50),XP(90),YP(90),fg);
  101.     for(ii = 0; ii < 100; ii++) {
  102.         GrPlot(XP((random() % 20) + 70),YP((random() % 40) + 50),fg);
  103.     }
  104. }
  105.  
  106.  
  107. #endif /* _TEST_H_ */
  108.  
  109.